filename = 'test.txt'

# r为读取模式 w为写入模式，默认为r
with open(filename,'w') as file_object:
    file_object.write('python')